home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / MISC / CLVRSTAT / PART2.TXT < prev   
Encoding:
Text File  |  1979-12-30  |  26.0 KB  |  541 lines

  1.  
  2. /*                                clvrstat.c v.1.10
  3.                         
  4. This program parses a CLOVER channel status file.  It prompts for the name of the HAL channel
  5. status file to be parsed.  Normally this has the format nnnnnnnn.tst, where nnnnnnnn is the
  6. input file's time tag.  Output to the console and the file "nnnnnnnn.sum" is various 
  7. summary statistics calculated from the status file.  Output to files called nnnnnnnn.MY 
  8. and nnnnnnnn.HIS separates the input data into space-delimited MY and HIS form suitable for 
  9. plotting or further analysis.  The program also makes a total of seven MY and HIS gnuplot setup files.  You can ignore these if you don't use gnuplot.  See the November 97 QEX paper for the names of these setup files and a description of their content.  
  10.  
  11. Preface all comment lines after the first in the HAL input file (as many as you want) with 
  12. a "#" (pound) symbol.  Note that many comments in the source code use the C++ comment-line marker ("//"), which is accepted by most modern C compilers.  If your compiler doesn't, enclose comments in the usual C comment symbols.
  13.  
  14. Note also that the program doesn't have all the crash tests of a commercial application.  
  15. Drive at your own risk! 
  16.  
  17. Plot-formatting file names are now DOS-compatible:
  18.  
  19. "mysnrtpt.plt"
  20. "hssnrtpt.plt"
  21. "myphsecc.plt"
  22. "hsphsecc.plt"
  23. "mydfreq.plt"
  24. "hsdfreq.plt"
  25. "myhspwr.plt"
  26.  
  27. Written by K. Wickwire.  5 May 1996.
  28.   
  29. Modifications.
  30.  
  31. v1.01 09.05.96 Output to input.MY and input.HIS.  Make plotset files.
  32. v1.02 17.05.96 Read    TO and FROM calls from input file.
  33. v1.03 01.06.96 Launch gnuplot on exit with (non-ANSI) exec() function.
  34.                (Not in this version.)                                                                                            
  35. v1.04 08.06.96 Re-organize plots: my/his snr&tput, phs&ecc, dfreq; 
  36.                make corresponding plot setup files.                                                                                            
  37. v1.05 03.01.97 Log time in input data as HH/MM/SS for gnuplot 3.6beta. 
  38. v1.06 13.04.97 Re-label "TO" and "FR" as "MY" and "HS". 
  39. v1.07 19.04.97 Extend treatment to FEC status data (only one callsign in file). 
  40. v1.08 14.08.97 Clean up for public distribution.
  41.                Use 8.3 plot setup names.
  42. v1.09 16.08.97 Set rmargin 5 characters wide ("set rmargin 5").
  43. v1.10 09.09.97 Modify to handle DSP4100 channel stats (auto power, etc.).
  44. */
  45.  
  46. #include <stdio.h>
  47. #include <string.h>                            //For string-processing.
  48. #include <stdlib.h>                            //For atoi(), etc.
  49. #include <math.h>                            //For sqrt().
  50. #include <time.h>                            //For date-time stamp.
  51.  
  52. #define numchars   70                        //Maximum input-file line length.
  53.  
  54. int main(void)
  55. {
  56. short  len,i,MY_call_found,HS_call_found;
  57. short  max_MY_tput,max_HS_tput,max_MY_SNR,max_HS_SNR;
  58. short  no_MY_lines,no_HS_lines,no_MY_XX,no_HS_XX;
  59. short  no_MY_num_ecc,no_HS_num_ecc;            //Nos. of numerical (non-XX) ecc percentages.
  60. short  no_MY_BPSM,no_MY_QPSM,no_MY_8PSM,no_MY_8P2A,no_MY_16P4A,no_MY_16PSM;
  61. short  no_HS_BPSM,no_HS_QPSM,no_HS_8PSM,no_HS_8P2A,no_HS_16P4A,no_HS_16PSM;
  62.  
  63. long   sum_MY_bias,sum_HS_bias,sum_MY_tput,sum_HS_tput,sum_MY_SNR,sum_HS_SNR;
  64. long   sum_MY_dfrq,sum_HS_dfrq,sum_MY_phs,sum_HS_phs,sum_MY_ecc,sum_HS_ecc;
  65. long   sum_MY_pwr,sum_HS_pwr;
  66.  
  67. long   sum_sq_MY_bias,sum_sq_HS_bias,sum_sq_MY_tput,sum_sq_HS_tput,sum_sq_MY_SNR;
  68. long   sum_sq_HS_SNR,sum_sq_MY_dfrq,sum_sq_HS_dfrq,sum_sq_MY_phs,sum_sq_HS_phs;
  69. long   sum_sq_MY_ecc,sum_sq_HS_ecc;
  70. long   sum_sq_MY_pwr,sum_sq_HS_pwr;
  71.  
  72. double avg_MY_bias,avg_HS_bias,avg_MY_tput,avg_HS_tput,avg_MY_SNR,avg_HS_SNR;
  73. double avg_MY_dfrq,avg_HS_dfrq,avg_MY_phs,avg_HS_phs,avg_MY_ecc,avg_HS_ecc;
  74. double avg_MY_pwr,avg_HS_pwr;
  75.  
  76. double sd_MY_bias,sd_HS_bias,sd_MY_tput,sd_HS_tput,sd_MY_SNR,sd_HS_SNR;
  77. double sd_MY_dfrq,sd_HS_dfrq,sd_MY_phs,sd_HS_phs,sd_MY_ecc,sd_HS_ecc;
  78. double sd_MY_pwr,sd_HS_pwr;
  79.  
  80. time_t     now;                                //For date-time stamping of files.
  81. struct     tm  *date;
  82. char       s[80];
  83.  
  84. int getline(char *line, int max, FILE *iop);    //Prototype for line-getter.
  85.  
  86. char fname0[20],fname1[30],fname2[30],fname3[30];
  87. char *ext1 = ".sum",*ext2 = ".MY",*ext3 = ".HIS";
  88. char MY[10];                                   //MYcall ("MY").  Handles AB1CDE-12.
  89. char HS[10];                                 //HIScall ("HS"). 
  90. char temp_hr[3],temp_min[3],temp_sec[3];    //For time conversion.
  91.  
  92. char line[numchars];
  93. char firststr[30],secondstr[10],thirdstr[10],fourthstr[10],fifthstr[10];    //Data-line strings.
  94. char sixthstr[10],seventhstr[10],eighthstr[10],ninthstr[10],tenthstr[10];
  95.                                                                                                                                                                                                                             
  96. FILE *input,*output1,*output2,*output3,*output4,*output5,*output6,*output7,*output8,*output9,*output10;
  97.                                         
  98. printf("Enter name of CLOVER input file: ");        //Get name of input file.
  99. scanf("%s", fname0);
  100.  
  101. if((input=fopen(fname0,"r")) == NULL)                //Open input file for read only.
  102.     {printf("Cannot open %s\n",fname0); return 0;}
  103.  
  104. for(i=0;i<30;i++)                                    //Initialize file names.
  105.     {fname1[i] = 0; fname2[i] = 0; fname3[i] = 0;}
  106.  
  107. strncpy(fname1,fname0,8);                  //Copy 1st 8 chars. of input file name into fname1.                                         
  108. strcat(fname1,ext1);                    //Add ".sum" to fname1 to make output file name.
  109. strncpy(fname2,fname0,8);                                                    
  110. strcat(fname2,ext2);                    //Make ("nnnnnnnn.MY") output file name.
  111. strncpy(fname3,fname0,8);                                                     
  112. strcat(fname3,ext3);                    //Make ("nnnnnnnn.HIS") output file name.
  113.                                                                                                                       
  114. if((output1=fopen(fname1,"w"))==NULL)        /*Open .sum file for statistics.*/
  115.     {printf("Cannot open main output file."); return 0;}    
  116. if((output2=fopen(fname2,"w"))==NULL)        /*Open .MY file for graph data.*/
  117.     {printf("Cannot open .MY file."); return 0;}
  118. if((output3=fopen(fname3,"w"))==NULL)        /*Open .HIS file for graph data.*/
  119.     {printf("Cannot open .HIS file."); return 0;}
  120. if((output4=fopen("mysnrtpt.plt","w"))==NULL)      /*Open plot file for parsed data.*/
  121.     {printf("Cannot open mysnrtpt.plt file."); return 0;}
  122. if((output5=fopen("hssnrtpt.plt","w"))==NULL)    /*Open plot file for parsed data.*/
  123.     {printf("Cannot open hssnrtpt.plt file."); return 0;}
  124. if((output6=fopen("myphsecc.plt","w"))==NULL)      /*Open plot file for parsed data.*/
  125.     {printf("Cannot open myphsecc.plt file."); return 0;}
  126. if((output7=fopen("hsphsecc.plt","w"))==NULL)    /*Open plot file for parsed data.*/
  127.     {printf("Cannot open hsphsecc.plt file."); return 0;}
  128. if((output8=fopen("mydfreq.plt","w"))==NULL)    /*Open plot file for parsed data.*/
  129.     {printf("Cannot open mydfreq.plt file."); return 0;}
  130. if((output9=fopen("hsdfreq.plt","w"))==NULL)    /*Open plot file for parsed data.*/
  131.     {printf("Cannot open hsdfreq.plt file."); return 0;}
  132. if((output10=fopen("myhspwr.plt","w"))==NULL)    /*Open plot file for parsed data.*/
  133.     {printf("Cannot open myhspwr.plt file."); return 0;}
  134.  
  135. len           = 0;                        //Initializations.
  136. MY_call_found = HS_call_found = 0;
  137. no_MY_lines   = no_HS_lines   = 0;
  138. no_MY_XX      = no_HS_XX      = 0;
  139. no_MY_BPSM    = no_MY_QPSM    = no_MY_8PSM = no_MY_8P2A = no_MY_16P4A = no_MY_16PSM = 0;
  140. no_HS_BPSM    = no_HS_QPSM    = no_HS_8PSM = no_HS_8P2A = no_HS_16P4A = no_HS_16PSM = 0;
  141.  
  142. sum_MY_bias = sum_HS_bias = 0;
  143. sum_MY_tput = sum_HS_tput = 0;          
  144. sum_MY_SNR  = sum_HS_SNR  = 0;
  145. sum_MY_dfrq = sum_HS_dfrq = 0;     
  146. sum_MY_phs  = sum_HS_phs  = 0;
  147. sum_MY_ecc  = sum_HS_ecc  = 0;     
  148. sum_MY_pwr  = sum_HS_pwr  = 0;
  149.  
  150. sum_sq_MY_bias = sum_sq_HS_bias    = 0;    
  151. sum_sq_MY_tput = sum_sq_HS_tput = 0;
  152. sum_sq_MY_SNR  = sum_sq_HS_SNR  = 0;    
  153. sum_sq_MY_dfrq = sum_sq_HS_dfrq = 0;
  154. sum_sq_MY_phs  = sum_sq_HS_phs  = 0;     
  155. sum_sq_MY_ecc  = sum_sq_HS_ecc  = 0;
  156. sum_sq_MY_pwr  = sum_sq_HS_pwr  = 0;
  157.  
  158. max_MY_tput = max_HS_tput = 0;
  159. max_MY_SNR  = max_HS_SNR  = 0;
  160.  
  161. time(&now);                                        //Get & write clock time.
  162. date = localtime(&now);
  163. strftime(s,80,"%d.%m.%y %H:%M:%S",date);
  164.  
  165.                                                 //Get MY and HS calls.
  166. while( (len != -1) && ((MY_call_found == 0) || (HS_call_found == 0)) )
  167.     {
  168.  
  169.     for(i=0;i<numchars;i++)                        //Initialize line[].
  170.             {line[i] = 0;}
  171.     for(i=0;i<10;i++)                            //Initialize strings to be parsed.
  172.             {firststr[i] = 0;secondstr[i] = 0;}
  173.                                         
  174.     len = getline(line, numchars, input);        //Get numchar characters from line.
  175.     if(len < 39) continue;                        //Skip first label line. MAKE SURE IT HAS < 39 CHARS!
  176.     if(line[0] == '#') continue;                //Skip line if it starts with "#" (comment line).
  177.     
  178.     for(i=0;i<numchars;i++)                        //Replace commas with spaces in data.
  179.     {if(line[i] == ',') line[i] = ' ';}
  180.  
  181.     if(MY_call_found == 0)                                                        
  182.         {
  183.         sscanf(&line[0],"%s %s",&firststr,&MY);    //Get MY call.
  184.         MY_call_found = 1;
  185.         continue;
  186.         }
  187.     if(HS_call_found == 0)
  188.         {
  189.         sscanf(&line[0],"%s %s",&firststr,&HS); //Get HS call.
  190.         HS_call_found = 1;
  191.         }
  192.     }                                            //End (first) while.
  193. rewind(input);                                    //Go back to beginning of input file.
  194.  
  195. printf("Statistical Summary of CLOVER channel status data:\n\n");
  196.  
  197. fprintf(output1,"Statistical Summary of CLOVER status data.\n");
  198. fprintf(output1,"Input file is [%s].\n",&fname0);
  199. fprintf(output1,"MYcall (\"MY\") = %s; HIScall (\"HS\") = %s.\n",MY,HS);
  200. fprintf(output1,"Summary date: %s\n\n",s);        //Time stamp results.
  201.  
  202. fprintf(output2,"#Status data for %s.\n",MY);
  203. fprintf(output2,"#Input file is [%s].\n",&fname0);
  204. fprintf(output2,"#Summary date: %s\n",s);
  205. fprintf(output2,"#(ecc = \"XX\" written as \"110\")\n\n",s);
  206. fprintf(output2,"#H/M/S   mod  b tp SNR df phs ecc pwr\n");    //Column labels.
  207.  
  208. fprintf(output3,"#Status data for %s.\n",HS);
  209. fprintf(output3,"#Input file is [%s].\n",&fname0);
  210. fprintf(output3,"#Summary date: %s\n",s);
  211. fprintf(output3,"#(ecc = \"XX\" written as \"110\")\n\n",s);
  212. fprintf(output3,"#H/M/S   mod  b tp SNR df  phs ecc pwr\n"); //Column labels.
  213.  
  214. while(len != -1)                    //While loop through data lines of input file.
  215.     {
  216.  
  217.     for(i=0;i<numchars;i++)            //Initialize line[].
  218.             {line[i] = 0;}
  219.     for(i=0;i<10;i++)                //Initialize strings to be parsed.
  220.             {firststr[i] = 0;secondstr[i] = 0;thirdstr[i] = 0;fourthstr[i] = 0;
  221.              fifthstr[i] = 0;sixthstr[i] = 0;seventhstr[i] = 0;eighthstr[i] = 0;            
  222.              ninthstr[i] = 0;tenthstr[i] = 0;}
  223.                                         
  224.     len = getline(line, numchars, input);    //Get numchar characters from line.
  225.     if(len < 39) continue;                    //Skip first label line (assumed < 39 chars).
  226.     if(line[0] == '#') continue;            //Skip line if it starts with "#".
  227.     for(i=0;i<numchars;i++)                    //Replace commas with spaces.
  228.     {if(line[i] == ',') line[i] = ' ';}
  229.                                                                                                     
  230.     sscanf(&line[0],"%s %s %s %s %s %s %s %s %s %s",
  231.     &firststr,&secondstr,&thirdstr,&fourthstr,&fifthstr,    
  232.     &sixthstr,&seventhstr,&eighthstr,&ninthstr,&tenthstr);
  233.                                         
  234.                                             //Line format:
  235.     //time  ,call    ,mod   ,b,tp,SNR, frq,phs,ecc,pwr    (b=bias; 1=robust,2=normal,3=fast)
  236.     //203808,KB1JY   ,BPSM  ,2,02,031,-3  ,024,000,000  (tp=thruput; 0-99 bytes/s)
  237.     //203808,W1IMM   ,BPSM  ,2,02,028, 003,031,050,000    (mod=BPSM,QPSM,8PSM)
  238.  
  239.       if(strcmp(secondstr,MY) == 0)               //Parse MY-lines.
  240.         {
  241.         no_MY_lines++;
  242.  
  243.         if(strcmp(thirdstr,"BPSM") == 0) no_MY_BPSM++;    //Count modulation choices.
  244.         if(strcmp(thirdstr,"QPSM") == 0) no_MY_QPSM++;
  245.         if(strcmp(thirdstr,"8PSM") == 0) no_MY_8PSM++;
  246.         if(strcmp(thirdstr,"8P2A") == 0) no_MY_8P2A++;
  247.         if(strcmp(thirdstr,"16P4A") == 0) no_MY_16P4A++;
  248.         if(strcmp(thirdstr,"16PSM") == 0) no_MY_16PSM++;
  249.  
  250.         sum_MY_bias    += atoi(fourthstr);
  251.         sum_MY_tput    += atoi(fifthstr);
  252.         sum_MY_SNR  += atoi(sixthstr);    
  253.         sum_MY_dfrq += atoi(seventhstr);
  254.         sum_MY_phs  += atoi(eighthstr);
  255.         sum_MY_pwr  += atoi(tenthstr);
  256.         
  257.         if(strcmp(ninthstr,"XX") == 0) 
  258.             {
  259.             no_MY_XX++;                            //Count # times ECC capacity is exceeded.
  260.             if(strcmp(MY,HS) == 0) no_HS_XX = no_MY_XX;        //To make FEC counts correct.
  261.                                                 //Replace "XX" with "110" (arbitrary replacement).
  262.             ninthstr[0] = '1'; ninthstr[1] = '1'; ninthstr[2] = '0';
  263.             }        
  264.         else                                         //Update ecc percentages.
  265.             {
  266.             sum_MY_ecc     += atoi(ninthstr);
  267.             sum_sq_MY_ecc  += atoi(ninthstr)*atoi(ninthstr);
  268.             if(strcmp(MY,HS) == 0)                    //File has FEC stats.
  269.                 {
  270.                 sum_HS_ecc     += atoi(ninthstr);
  271.                 sum_sq_HS_ecc  += atoi(ninthstr)*atoi(ninthstr);
  272.                 }
  273.             }
  274.  
  275.         sum_sq_MY_bias += atoi(fourthstr)*atoi(fourthstr);
  276.         sum_sq_MY_tput += atoi(fifthstr)*atoi(fifthstr);
  277.         sum_sq_MY_SNR  += atoi(sixthstr)*atoi(sixthstr);
  278.         sum_sq_MY_dfrq += atoi(seventhstr)*atoi(seventhstr);
  279.         sum_sq_MY_phs  += atoi(eighthstr)*atoi(eighthstr);
  280.         sum_sq_MY_pwr  += atoi(tenthstr)*atoi(tenthstr);
  281.         
  282.         if(atoi(fifthstr) > max_MY_tput) max_MY_tput = atoi(fifthstr);    //Update max tput.
  283.         if(atoi(sixthstr) > max_MY_SNR)  max_MY_SNR  = atoi(sixthstr);    //Update max SNR.
  284.  
  285.         sprintf(temp_hr,"%c%c",firststr[0],firststr[1]);    //Get time tag.
  286.         sprintf(temp_min,"%c%c",firststr[2],firststr[3]);
  287.         sprintf(temp_sec,"%c%c",firststr[4],firststr[5]);
  288.         
  289.                                                     //Print time-tagged data to "MYcall" file.
  290.         fprintf(output2,"%s/%s/%s %s %s %s %s %s %s %s %s\n",
  291.         temp_hr,temp_min,temp_sec,thirdstr,fourthstr,fifthstr,
  292.         sixthstr,seventhstr,eighthstr,ninthstr,tenthstr);
  293.  
  294.         }                                            //End MY-line processing.                                                                                    
  295.  
  296.       if(strcmp(secondstr,HS) == 0)                       //Parse HS-lines.
  297.         {
  298.         no_HS_lines++;
  299.                                                     //Count modulation choices.
  300.         if(strcmp(thirdstr,"BPSM") == 0) no_HS_BPSM++;    
  301.         if(strcmp(thirdstr,"QPSM") == 0) no_HS_QPSM++;
  302.         if(strcmp(thirdstr,"8PSM") == 0) no_HS_8PSM++;
  303.         if(strcmp(thirdstr,"8P2A") == 0) no_HS_8P2A++;
  304.         if(strcmp(thirdstr,"16P4A") == 0) no_HS_16P4A++;
  305.         if(strcmp(thirdstr,"16PSM") == 0) no_HS_16PSM++;
  306.         
  307.         sum_HS_bias    += atoi(fourthstr);
  308.         sum_HS_tput    += atoi(fifthstr);
  309.         sum_HS_SNR  += atoi(sixthstr);    
  310.         sum_HS_dfrq += atoi(seventhstr);
  311.         sum_HS_phs  += atoi(eighthstr);
  312.         sum_HS_pwr  += atoi(tenthstr);
  313.         
  314.         if(strcmp(MY,HS) != 0)                    //Different MY and HS calls.
  315.             {
  316.             if(strcmp(ninthstr,"XX") == 0)
  317.                 {
  318.                 no_HS_XX++;                        //Count # times ECC capacity is exceeded.
  319.                                                 //NOTE: ALREADY SET ABOVE TO 110 IN FEC DATA!
  320.                 ninthstr[0] = '1'; ninthstr[1] = '1'; ninthstr[2] = '0';    
  321.                 }
  322.             else                                 //Update ecc percentages.
  323.                 {
  324.                 sum_HS_ecc     += atoi(ninthstr);
  325.                 sum_sq_HS_ecc  += atoi(ninthstr)*atoi(ninthstr);
  326.                 }
  327.             }                                    //End if(strcmp(MY,HS) != 0).
  328.  
  329.         sum_sq_HS_bias += atoi(fourthstr)*atoi(fourthstr);
  330.         sum_sq_HS_tput += atoi(fifthstr)*atoi(fifthstr);
  331.         sum_sq_HS_SNR  += atoi(sixthstr)*atoi(sixthstr);
  332.         sum_sq_HS_dfrq += atoi(seventhstr)*atoi(seventhstr);
  333.         sum_sq_HS_phs  += atoi(eighthstr)*atoi(eighthstr);
  334.         sum_sq_HS_pwr  += atoi(tenthstr)*atoi(tenthstr);
  335.         
  336.         if(atoi(fifthstr) > max_HS_tput) max_HS_tput = atoi(fifthstr);
  337.         if(atoi(sixthstr) > max_HS_SNR)  max_HS_SNR  = atoi(sixthstr);        
  338.  
  339.         sprintf(temp_hr,"%c%c",firststr[0],firststr[1]);
  340.         sprintf(temp_min,"%c%c",firststr[2],firststr[3]);
  341.         sprintf(temp_sec,"%c%c",firststr[4],firststr[5]);
  342.                                                             //Print data to "HIScall" file.
  343.         fprintf(output3,"%s/%s/%s %s %s %s %s %s %s %s %s\n",
  344.         temp_hr,temp_min,temp_sec,thirdstr,fourthstr,fifthstr,\
  345.         sixthstr,seventhstr,eighthstr,ninthstr,tenthstr);        
  346.  
  347. }                                //End HS-line processing.
  348.  
  349.     }                            //End while-loop through lines.
  350.  
  351. if((no_MY_lines < 2) ||    (no_HS_lines < 2))
  352.     {printf("Not enough data for statistics.\n"); return 0;}
  353.  
  354. avg_MY_bias      = (double)sum_MY_bias/no_MY_lines;            //Calculate averages.
  355. avg_HS_bias     = (double)sum_HS_bias/no_HS_lines;
  356. avg_MY_tput      = (double)sum_MY_tput/no_MY_lines;
  357. avg_HS_tput     = (double)sum_HS_tput/no_HS_lines;
  358. avg_MY_SNR      = (double)sum_MY_SNR/no_MY_lines;
  359. avg_HS_SNR      = (double)sum_HS_SNR/no_HS_lines;
  360. avg_MY_dfrq      = (double)sum_MY_dfrq/no_MY_lines;
  361. avg_HS_dfrq     = (double)sum_HS_dfrq/no_HS_lines;
  362. avg_MY_phs      = (double)sum_MY_phs/no_MY_lines;
  363. avg_HS_phs      = (double)sum_HS_phs/no_HS_lines;
  364. avg_MY_pwr      = (double)sum_MY_pwr/no_MY_lines;
  365. avg_HS_pwr      = (double)sum_HS_pwr/no_HS_lines;
  366.  
  367. no_MY_num_ecc = no_MY_lines - no_MY_XX;        //Calculate #s of numerical ecc percentages.
  368. no_HS_num_ecc = no_HS_lines - no_HS_XX;
  369.  
  370. if((no_MY_num_ecc < 2) || (no_HS_num_ecc < 2))
  371.     {printf("Not enough data for statistics.\n"); return 0;}
  372.  
  373. avg_MY_ecc      = (double)sum_MY_ecc/no_MY_num_ecc;
  374. avg_HS_ecc      = (double)sum_HS_ecc/no_HS_num_ecc;
  375.                                                         //Calculate standard deviations.
  376. sd_MY_bias      = sqrt((double)sum_sq_MY_bias/(no_MY_lines - 1) - (double)no_MY_lines*avg_MY_bias*avg_MY_bias/(no_MY_lines - 1));
  377. sd_HS_bias      = sqrt((double)sum_sq_HS_bias/(no_HS_lines - 1) - (double)no_HS_lines*avg_HS_bias*avg_HS_bias/(no_HS_lines - 1));
  378. sd_MY_tput      = sqrt((double)sum_sq_MY_tput/(no_MY_lines - 1) - (double)no_MY_lines*avg_MY_tput*avg_MY_tput/(no_MY_lines - 1));
  379. sd_HS_tput      = sqrt((double)sum_sq_HS_tput/(no_HS_lines - 1) - (double)no_HS_lines*avg_HS_tput*avg_HS_tput/(no_HS_lines - 1));
  380. sd_MY_SNR           = sqrt((double)sum_sq_MY_SNR/(no_MY_lines - 1) - (double)no_MY_lines*avg_MY_SNR*avg_MY_SNR/(no_MY_lines - 1));
  381. sd_HS_SNR       = sqrt((double)sum_sq_HS_SNR/(no_HS_lines - 1) - (double)no_HS_lines*avg_HS_SNR*avg_HS_SNR/(no_HS_lines - 1));
  382. sd_MY_dfrq      = sqrt((double)sum_sq_MY_dfrq/(no_MY_lines - 1) - (double)no_MY_lines*avg_MY_dfrq*avg_MY_dfrq/(no_MY_lines - 1));
  383. sd_HS_dfrq      = sqrt((double)sum_sq_HS_dfrq/(no_HS_lines - 1) - (double)no_HS_lines*avg_HS_dfrq*avg_HS_dfrq/(no_HS_lines - 1));
  384. sd_MY_phs            = sqrt((double)sum_sq_MY_phs/(no_MY_lines - 1) - (double)no_MY_lines*avg_MY_phs*avg_MY_phs/(no_MY_lines - 1));
  385. sd_HS_phs       = sqrt((double)sum_sq_HS_phs/(no_HS_lines - 1) - (double)no_HS_lines*avg_HS_phs*avg_HS_phs/(no_HS_lines - 1));
  386. sd_MY_ecc            = sqrt((double)sum_sq_MY_ecc/(no_MY_num_ecc - 1) - (double)no_MY_num_ecc*avg_MY_ecc*avg_MY_ecc/(no_MY_num_ecc - 1));
  387. sd_HS_ecc       = sqrt((double)sum_sq_HS_ecc/(no_HS_num_ecc - 1) - (double)no_HS_num_ecc*avg_HS_ecc*avg_HS_ecc/(no_HS_num_ecc - 1));
  388. sd_MY_pwr            = sqrt((double)sum_sq_MY_pwr/(no_MY_lines - 1) - (double)no_MY_lines*avg_MY_pwr*avg_MY_pwr/(no_MY_lines - 1));
  389. sd_HS_pwr       = sqrt((double)sum_sq_HS_pwr/(no_HS_lines - 1) - (double)no_HS_lines*avg_HS_pwr*avg_HS_pwr/(no_HS_lines - 1));
  390.  
  391. printf("Number of reports on %s = %d\n",MY,no_MY_lines);    //Print stats.
  392. printf("Number of reports on %s = %d\n\n",HS,no_HS_lines);
  393.  
  394. printf("E(MY_bias) = %2.1f, sd(MY_bias) = %3.2f\n",avg_MY_bias,sd_MY_bias);
  395. printf("E(HS_bias) = %2.1f, sd(HS_bias) = %3.2f\n",avg_HS_bias,sd_HS_bias);
  396. printf("E(MY_tput) = %4.2f cps, sd(MY_tput) = %4.2f cps\n",avg_MY_tput,sd_MY_tput);
  397. printf("E(HS_tput) = %4.2f cps, sd(HS_tput) = %4.2f cps\n",avg_HS_tput,sd_HS_tput);
  398. printf("E(MY_SNR)  = %4.2f dB, sd(MY_SNR) = %4.2f dB\n",avg_MY_SNR,sd_MY_SNR);
  399. printf("E(HS_SNR)  = %4.2f dB, sd(HS_SNR) = %4.2f dB\n",avg_HS_SNR,sd_HS_SNR);
  400. printf("E(MY_dfrq) = %4.2f Hz, sd(MY_dfrq) = %4.2f Hz\n",avg_MY_dfrq,sd_MY_dfrq);
  401. printf("E(HS_dfrq) = %4.2f Hz, sd(HS_dfrq) = %4.2f Hz\n",avg_HS_dfrq,sd_HS_dfrq);
  402. printf("E(MY_phs)  = %4.2f deg., sd(MY_phs) = %4.2f deg.\n",avg_MY_phs,sd_MY_phs);
  403. printf("E(HS_phs)  = %4.2f deg., sd(HS_phs) = %4.2f deg.\n",avg_HS_phs,sd_HS_phs);
  404. printf("E(MY_ecc)  = %4.2f%%, sd(MY_ecc) = %4.2f%%\n",avg_MY_ecc,sd_MY_ecc);
  405. printf("E(HS_ecc)  = %4.2f%%, sd(HS_ecc) = %4.2f%%\n",avg_HS_ecc,sd_HS_ecc);
  406. printf("E(MY_pwr)  = %4.2f%%, sd(MY_pwr) = %4.2f%%\n",avg_MY_pwr,sd_MY_pwr);
  407. printf("E(HS_pwr)  = %4.2f%%, sd(HS_pwr) = %4.2f%%\n\n",avg_HS_pwr,sd_HS_pwr);
  408.  
  409. printf("Error correcting capability exceeded %d time%c on MY link\n",no_MY_XX,(no_MY_XX==1)?' ':'s');
  410. printf("Error correcting capability exceeded %d time%c on HS link\n\n",no_HS_XX,(no_HS_XX==1)?' ':'s');
  411.  
  412. printf("maximum \"MY\" throughput = %d cps, maximum \"MY\" SNR = %d dB\n",max_MY_tput,max_MY_SNR);
  413. printf("maximum \"HS\" throughput = %d cps, maximum \"HS\" SNR = %d dB\n\n",max_HS_tput,max_HS_SNR);
  414.  
  415. printf("Modulation counts:\n");
  416. printf("MY: %d BPSM %d QPSM %d 8PSM %d 8P2A %d 16P4A %d 16PSM\n",no_MY_BPSM,no_MY_QPSM,no_MY_8PSM,no_MY_8P2A,no_MY_16P4A,no_MY_16PSM);
  417. printf("HS: %d BPSM %d QPSM %d 8PSM %d 8P2A %d 16P4A %d 16PSM\n",no_HS_BPSM,no_HS_QPSM,no_HS_8PSM,no_HS_8P2A,no_HS_16P4A,no_HS_16PSM);
  418.  
  419. fprintf(output1,"Number of reports on %s = %d\n",MY,no_MY_lines);        
  420. fprintf(output1,"Number of reports on %s = %d\n\n",HS,no_HS_lines);
  421.  
  422. fprintf(output1,"E(MY_bias) = %2.1f, sd(MY_bias) = %3.2f\n",avg_MY_bias,sd_MY_bias);
  423. fprintf(output1,"E(HS_bias) = %2.1f, sd(HS_bias) = %3.2f\n",avg_HS_bias,sd_HS_bias);
  424. fprintf(output1,"E(MY_tput) = %4.2f cps, sd(MY_tput) = %4.2f cps\n",avg_MY_tput,sd_MY_tput);
  425. fprintf(output1,"E(HS_tput) = %4.2f cps, sd(HS_tput) = %4.2f cps\n",avg_HS_tput,sd_HS_tput);
  426. fprintf(output1,"E(MY_SNR)  = %4.2f dB, sd(MY_SNR) = %4.2f dB\n",avg_MY_SNR,sd_MY_SNR);
  427. fprintf(output1,"E(HS_SNR)  = %4.2f dB, sd(HS_SNR) = %4.2f dB\n",avg_HS_SNR,sd_HS_SNR);
  428. fprintf(output1,"E(MY_dfrq) = %4.2f Hz, sd(MY_dfrq) = %4.2f Hz\n",avg_MY_dfrq,sd_MY_dfrq);
  429. fprintf(output1,"E(HS_dfrq) = %4.2f Hz, sd(HS_dfrq) = %4.2f Hz\n",avg_HS_dfrq,sd_HS_dfrq);
  430. fprintf(output1,"E(MY_phs)  = %4.2f deg., sd(MY_phs) = %4.2f deg.\n",avg_MY_phs,sd_MY_phs);
  431. fprintf(output1,"E(HS_phs)  = %4.2f deg., sd(HS_phs) = %4.2f deg.\n",avg_HS_phs,sd_HS_phs);
  432. fprintf(output1,"E(MY_ecc)  = %4.2f%%, sd(MY_ecc) = %4.2f%%\n",avg_MY_ecc,sd_MY_ecc);
  433. fprintf(output1,"E(HS_ecc)  = %4.2f%%, sd(HS_ecc) = %4.2f%%\n",avg_HS_ecc,sd_HS_ecc);
  434. fprintf(output1,"E(MY_pwr)  = %4.2f%%, sd(MY_pwr) = %4.2f%%\n",avg_MY_pwr,sd_MY_pwr);
  435. fprintf(output1,"E(HS_pwr)  = %4.2f%%, sd(HS_pwr) = %4.2f%%\n\n",avg_HS_pwr,sd_HS_pwr);
  436.  
  437. fprintf(output1,"Error correcting capability exceeded %d time%c on MY link\n",no_MY_XX,(no_MY_XX==1)?' ':'s');
  438. fprintf(output1,"Error correcting capability exceeded %d time%c on HS link\n\n",no_HS_XX,(no_HS_XX==1)?' ':'s');
  439.  
  440. fprintf(output1,"maximum \"MY\" throughput = %d cps, maximum \"MY\" SNR = %d dB\n",max_MY_tput,max_MY_SNR);
  441. fprintf(output1,"maximum \"HS\" throughput = %d cps, maximum \"HS\" SNR = %d dB\n\n",max_HS_tput,max_HS_SNR);
  442.  
  443. fprintf(output1,"Modulation counts:\n");
  444. fprintf(output1,"MY: %d BPSM %d QPSM %d 8PSM %d 8P2A %d 16P4A %d 16PSM\n",no_MY_BPSM,no_MY_QPSM,no_MY_8PSM,no_MY_8P2A,no_MY_16P4A,no_MY_16PSM);
  445. fprintf(output1,"HS: %d BPSM %d QPSM %d 8PSM %d 8P2A %d 16P4A %d 16PSM\n",no_HS_BPSM,no_HS_QPSM,no_HS_8PSM,no_HS_8P2A,no_HS_16P4A,no_HS_16PSM);
  446.  
  447.                                         //Write mysnrtpt setup file for gnuplot.
  448. fprintf(output4,"set pointsize 1\n");
  449. fprintf(output4,"set rmargin 5\n");
  450. fprintf(output4,"set timefmt \"%%H/%%M/%%S\"\n");
  451. fprintf(output4,"set xdata time\n");
  452. fprintf(output4,"set format x \"%%H/%%M/%%S\"\n");
  453. fprintf(output4,"set xlabel \"[input: %s]          time (HH/MM/SS) -->\"\n",fname0);
  454. fprintf(output4,"set title \"%s: E(tpt) = %4.2f cps E(SNR) = %4.2f dB\"\n",\
  455. MY,avg_MY_tput,avg_MY_SNR);
  456. fprintf(output4,"plot '%s' using 1:4 title \"tpt\" with linespoints 1 1,\
  457. '%s' using 1:5 title \"SNR\" with linespoints 3 3",fname2,fname2);
  458.  
  459.                                         //Write hssnrtpt setup file for gnuplot.
  460. fprintf(output5,"set pointsize 1\n");
  461. fprintf(output5,"set rmargin 5\n");
  462. fprintf(output5,"set timefmt \"%%H/%%M/%%S\"\n");
  463. fprintf(output5,"set xdata time\n");
  464. fprintf(output5,"set format x \"%%H/%%M/%%S\"\n");
  465. fprintf(output5,"set xlabel \"[input: %s]          time (HH/MM/SS) -->\"\n",fname0);
  466. fprintf(output5,"set title \"%s: E(tpt) = %4.2f cps E(SNR) = %4.2f dB\"\n",\
  467. HS,avg_HS_tput,avg_HS_SNR);
  468. fprintf(output5,"plot '%s' using 1:4 title \"tpt\" with linespoints 1 1,\
  469. '%s' using 1:5 title \"SNR\" with linespoints 3 3",fname3,fname3);
  470.  
  471.                                         //Write myphsecc setup file for gnuplot.
  472. fprintf(output6,"set pointsize 1\n");
  473. fprintf(output6,"set rmargin 5\n");
  474. fprintf(output6,"set timefmt \"%%H/%%M/%%S\"\n");
  475. fprintf(output6,"set xdata time\n");
  476. fprintf(output6,"set format x \"%%H/%%M/%%S\"\n");
  477. fprintf(output6,"set xlabel \"[input: %s]          time (HH/MM/SS) -->\"\n",fname0);
  478. fprintf(output6,"set title \"%s: E(phs) = %4.2f deg. E(ecc|<= 100) = %4.2f%%\"\n",\
  479. MY,avg_MY_phs,avg_MY_ecc);
  480. fprintf(output6,"plot '%s' using 1:7 title \"phs\" with linespoints 1 1,\
  481. '%s' using 1:8 title \"ecc\" with linespoints 3 3",fname2,fname2);
  482.  
  483.                                         //Write hsphsecc setup file for gnuplot.
  484. fprintf(output7,"set pointsize 1\n");
  485. fprintf(output7,"set rmargin 5\n");
  486. fprintf(output7,"set timefmt \"%%H/%%M/%%S\"\n");
  487. fprintf(output7,"set xdata time\n");
  488. fprintf(output7,"set format x \"%%H/%%M/%%S\"\n");
  489. fprintf(output7,"set xlabel \"[input: %s]          time (HH/MM/SS) -->\"\n",fname0);
  490. fprintf(output7,"set title \"%s: E(phs) = %4.2f deg. E(ecc|<= 100) = %4.2f%%\"\n",\
  491. HS,avg_HS_phs,avg_HS_ecc);
  492. fprintf(output7,"plot '%s' using 1:7 title \"phs\" with linespoints 1 1,\
  493. '%s' using 1:8 title \"ecc\" with linespoints 3 3",fname3,fname3);
  494.  
  495.                                         //Write mydfreq setup file for gnuplot.
  496. fprintf(output8,"set pointsize 1\n");
  497. fprintf(output8,"set rmargin 5\n");
  498. fprintf(output8,"set timefmt \"%%H/%%M/%%S\"\n");
  499. fprintf(output8,"set xdata time\n");
  500. fprintf(output8,"set format x \"%%H/%%M/%%S\"\n");
  501. fprintf(output8,"set xlabel \"[input: %s]          time (HH/MM/SS) -->\"\n",fname0);
  502. fprintf(output8,"set title \"%s: E(dfreq) = %4.2f deg.\"\n",MY,avg_MY_dfrq);
  503. fprintf(output8,"plot '%s' using 1:6 title \"dfreq\" with linespoints 1 1",fname2);
  504.  
  505.                                         //Write hsdfreq setup file for gnuplot.
  506. fprintf(output9,"set pointsize 1\n");
  507. fprintf(output9,"set rmargin 5\n");
  508. fprintf(output9,"set timefmt \"%%H/%%M/%%S\"\n");
  509. fprintf(output9,"set xdata time\n");
  510. fprintf(output9,"set format x \"%%H/%%M/%%S\"\n");
  511. fprintf(output9,"set xlabel \"[input: %s]          time (HH/MM/SS) -->\"\n",fname0);
  512. fprintf(output9,"set title \"%s: E(dfreq) = %4.2f deg.\"\n",HS,avg_HS_dfrq);
  513. fprintf(output9,"plot '%s' using 1:6 title \"dfreq\" with linespoints 1 1",fname3);
  514.  
  515.                                         //Write myhspwr setup file for gnuplot.
  516. fprintf(output10,"set pointsize 1\n");
  517. fprintf(output10,"set rmargin 5\n");
  518. fprintf(output10,"set timefmt \"%%H/%%M/%%S\"\n");
  519. fprintf(output10,"set xdata time\n");
  520. fprintf(output10,"set format x \"%%H/%%M/%%S\"\n");
  521. fprintf(output10,"set xlabel \"[input: %s]          time (HH/MM/SS) -->\"\n",fname0);
  522. fprintf(output10,"set title \"%s: E(pwr) = %4.2f%%   %s: E(pwr) = %4.2f%%.\"\n",MY,avg_MY_pwr,HS,avg_HS_pwr);
  523. fprintf(output10,"plot '%s' using 1:9 title \"mypwr\" with linespoints 1 1,\
  524. '%s' using 1:9 title \"hspwr\" with linespoints 3 3",fname2,fname3);
  525.  
  526. return(0);
  527. }                                        //End main().
  528.  
  529. /*************************************************************************************
  530. getline function: reads a line, returns its length.
  531. *************************************************************************************/
  532. int getline(char *line, int max, FILE *iop)
  533.  
  534. {
  535.     if(fgets(line, max, iop) == NULL)
  536.         return -1;
  537.     else
  538.         return strlen(line);
  539. }                                            //End getline function.
  540.  
  541.